package com.pro.common.service.sitecontent.enums.init;

import com.pro.common.api.CommonConst;
import com.pro.common.api.enums.EnumSysRole;
import com.pro.common.service.sitecontent.model.db.AuthRoute;
import com.pro.framework.api.enums.IEnumToDbDbCode;
import com.pro.framework.api.enums.IEnumToDbEnum;

public interface IEnumToDbAuthRoute extends IEnumToDbDbCode, IAuthRoute {
    @Override
    default String getToDbCode() {
        return IAuthRoute.super.getToDbCode();
    }

    default void setToDbCode(String code) {
        String[] split = code.split(CommonConst.Str.SPLIT);
        setSysRole(EnumSysRole.valueOf(split[0]));
        setGroupCode("".equals(split[1]) ? null : split[1]);
        setServiceName("".equals(split[2]) ? null : split[2]);
        setCode(split[3]);
    }

    void setGroupCode(String groupCode);

    void setServiceName(String serviceName);

    void setCode(String code);

    void setSysRole(EnumSysRole sysRole);
}
